package com.matt.sooncleaner.menu

import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.view.ViewGroup.LayoutParams
import androidx.activity.ComponentDialog
import com.airbnb.lottie.LottieAnimationView
import com.matt.sooncleaner.R

class RateDialog(context: Context) : ComponentDialog(context, R.style.RateDialogTheme) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.dialog_rate)
        findViewById<View>(R.id.closeView).setOnClickListener { dismiss() }
        val lottieAnimView = findViewById<LottieAnimationView>(R.id.lottie_anim)
        lottieAnimView.setOnClickListener {
            RateUtils.setClickRate()
            dismiss()
        }
        window?.let {
            it.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
            it.attributes?.gravity = Gravity.CENTER
        }
    }
}